{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\burlacue\Dropbox\Corruption papper\DATAVERSE\marginal_effect_model6.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}19 Oct 2017, 12:35:39
{txt}
{com}. 
. **** This code can be used to generate line a in Table 3 
. * "Average marginal effects of ideological proximity conditional
. *on the level of corruption, perceptual accuracy and political efficacy
. *and their 95% confidence intervals" in the article
. 
. ** The code has been generated based on Hanmer and Kalkan(2013) online Appendix
. * AJPS_602_sm_suppmatS1.docx available at 
. * http://onlinelibrary.wiley.com/doi/10.1111/j.1540-5907.2012.00602.x/abstract
. 
. * Hanmer, M. J. and K. O. Kalkan (2013). Behind the curve: Clarifying the best 
. * approach to calculating predicted probabilities and marginal effects from 
. * limited dependent variable models. American Journal of Political Science 57 (1),
. * 263–277
. 
. ***The measures for corruption should be purchased from the PRG Group. 
. *In this article, I used the monthy measures of corruption from Table 3b and 
. *calculated the annual averages:
. *forvalues i=1984/2016{c -(}
. *gen corruption`i'= _01_`i'+_02_`i'+ _03_`i'+_04_`i'+ _05_`i' + _06_`i'+ ///
> *_07_`i'+_08_`i'+ _09_`i'+_10_`i'+ _11_`i' + _12_`i'
. *{c )-}
. *drop Variable _01_1984 - _01_2017
. *reshape long corruption, i(Country) j(year)
. 
. ** These should be merged with the data. Make sure the variable is called corruption 
. 
. ** The dataset DOES NOT include a variable for corruption!!!
. 
. clear all
{txt}
{com}. 
. set mem 1000m
{txt}{bf:set memory} ignored.
{p 4 4 2}
Memory no longer
needs to be set in modern Statas;
memory adjustments are performed on the fly
automatically.
{p_end}

{com}. set maxvar 32767

{txt}
{com}. 
. set seed 99
{txt}
{com}. estimates use sem2 // See probit-models-of-vote-for-the-incumbent
{res}{txt}
{com}. 
. mat b=e(b)
{txt}
{com}. mat V=e(V)
{txt}
{com}. 
. 
. drawnorm corruption_b ideolcor_b ideolprime_b externalef_b interaction3_b ///
> age_b male_b income_b loweducation_b higheducation_b unemployed_b retired_b /// 
> other_b partisan_b growth_b gdp_b durable_b partyage_b pr_b pluralty_b ///
>  mdmh_b p_effnv_b   p_maj_b  state_b east_b noneuro_b  system_b cons_b ///
>  a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 ///
>  a22 a23 a24 a25 , mean(b) cov(V) n(1000)
{txt}(obs 1,000)

{com}.   
.   
. merge using recoded_CSES_data.dta
{txt}{p}
(note: you are using old
{bf:merge} syntax; see
{bf:{help merge:[D] merge}} for new syntax)
{p_end}

{com}. 
. 
. *** Effect of ideolprime when corruption is low (0.1)
. 
. replace corruption=0.1
{txt}(60,665 real changes made)

{com}. 
. // calculate the marginal effect of ideological proximity when political
. // efficacy is low (0.25) and high (1)
.  
. foreach j of numlist 25 100 {c -(}   
{txt}  2{com}. 
.  replace externalef=`j'
{txt}  3{com}.  
.  gen eff_ideol_`j'=.
{txt}  4{com}. 
.  replace externalef=`j'/100
{txt}  5{com}.  
. 
.  
.   quietly  forvalues i=1/1000{c -(}
{txt}  6{com}.  gen p_`i'=normalden(corruption_b[`i']*corruption + ///
>  ideolcor_b[`i']*ideolprime*corruption + ideolprime_b[`i']*ideolprime + ///
>  externalef_b[`i']*externalef + interaction3_b[`i']*externalef*ideolprime +  ///
> age_b[`i']*age + male_b[`i']*male + income_b[`i']*income +  ///
> loweducation_b[`i']*loweducation +  higheducation_b[`i']*higheducation + ///
> unemployed_b[`i']*unemployed + retired_b[`i']*retired + other_b[`i']*other + ///
>  partisan_b[`i']*partisan + gdp_b[`i']*gdp + durable_b[`i']*durable + ///
>  partyage_b[`i']*partyage + pr_b[`i']*pr + pluralty_b[`i']*pluralty +  ///
>  mdmh_b[`i']*mdmh + p_effnv_b[`i']*p_effnv +   p_maj_b[`i']*p_maj + ///
>  state_b[`i']*state_b + east_b[`i']*east + noneuro_b[`i']*noneuro + ///
>  system_b[`i']*system + growth_b[`i']*growth + ///
> cons_b[`i'])*(ideolcor_b[`i']*corruption+ ideolprime_b[`i'] + ///
>  interaction3_b[`i']*externalef)
{txt}  7{com}.  
.  sum p_`i', meanonly
{txt}  8{com}.  
.  replace eff_ideol_`j'=r(mean) in `i'
{txt}  9{com}.  {c )-}
{txt} 10{com}.  drop p_1-p_1000
{txt} 11{com}.  
.   {c )-}
{txt}(66,987 real changes made)
(66,987 missing values generated)
(66,987 real changes made)
(66,987 real changes made)
(66,987 missing values generated)
(66,987 real changes made)

{com}.   
.  gen effect_lc=. // estimate
{txt}(66,987 missing values generated)

{com}.   gen effect_l_lc=. // low value of 95% confidence interval
{txt}(66,987 missing values generated)

{com}.  gen effect_u_lc=. // high value of 95% confidence interval
{txt}(66,987 missing values generated)

{com}. 
.   
. foreach k of numlist  25 100 {c -(}
{txt}  2{com}.  sum eff_ideol_`k', meanonly
{txt}  3{com}.  replace effect_lc=r(mean) in `k'
{txt}  4{com}.  centile eff_ideol_`k', centile(2.5)
{txt}  5{com}.   replace effect_l_lc=r(c_1) in `k'
{txt}  6{com}.  centile eff_ideol_`k', centile(97.5)
{txt}  7{com}.   replace effect_u_lc=r(c_1) in `k'
{txt}  8{com}.   {c )-}
{txt}(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideol_25 {c |}{col 14}{res}     1,000{col 29}    2.5{col 39} .0094816{col 55} .0090109{col 67} .0098393{txt}
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideol_25 {c |}{col 14}{res}     1,000{col 29}   97.5{col 39} .0212077{col 55} .0208686{col 67} .0219424{txt}
(1 real change made)
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideo~100 {c |}{col 14}{res}     1,000{col 29}    2.5{col 39} .0166601{col 55} .0160337{col 67} .0173731{txt}
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideo~100 {c |}{col 14}{res}     1,000{col 29}   97.5{col 39} .0292108{col 55} .0284338{col 67} .0296773{txt}
(1 real change made)

{com}.   
.   
. drop eff_ideol_25 eff_ideol_100
{txt}
{com}. 
. 
. 
. *** Effect of ideolprime when corruption is high
. 
. replace corruption=0.8
{txt}(66,987 real changes made)

{com}. 
. 
.  
. foreach j of numlist 25 100 {c -(}   
{txt}  2{com}.  
.  gen eff_ideol_`j'=.
{txt}  3{com}. 
.  replace externalef=`j'/100
{txt}  4{com}.  
.  // calculate the marginal effect of ideological proximity when political
. // efficacy is low (0.25) and high (1)
. 
.   quietly forvalues i=1/1000{c -(}
{txt}  5{com}.  gen p_`i'=normalden(corruption_b[`i']*corruption + ///
>  ideolcor_b[`i']*ideolprime*corruption + ideolprime_b[`i']*ideolprime + ///
>  externalef_b[`i']*externalef + interaction3_b[`i']*externalef*ideolprime +  ///
> age_b[`i']*age + male_b[`i']*male + income_b[`i']*income +  ///
> loweducation_b[`i']*loweducation +  higheducation_b[`i']*higheducation + ///
> unemployed_b[`i']*unemployed + retired_b[`i']*retired + other_b[`i']*other + ///
>  partisan_b[`i']*partisan + gdp_b[`i']*gdp + durable_b[`i']*durable + ///
>  partyage_b[`i']*partyage + pr_b[`i']*pr + pluralty_b[`i']*pluralty +  ///
>  mdmh_b[`i']*mdmh + p_effnv_b[`i']*p_effnv +   p_maj_b[`i']*p_maj + ///
>  state_b[`i']*state_b + east_b[`i']*east + noneuro_b[`i']*noneuro + ///
>  system_b[`i']*system + growth_b[`i']*growth + ///
> cons_b[`i'])*(ideolcor_b[`i']*corruption+ ideolprime_b[`i'] + ///
>  interaction3_b[`i']*externalef)
{txt}  6{com}.  
.  sum p_`i', meanonly
{txt}  7{com}.  
.  replace eff_ideol_`j'=r(mean) in `i'
{txt}  8{com}.  {c )-}
{txt}  9{com}.  drop p_1-p_1000
{txt} 10{com}.  
.   {c )-}
{txt}(66,987 missing values generated)
(66,987 real changes made)
(66,987 missing values generated)
(66,987 real changes made)

{com}.   
.  gen effect_hc=. // estimate
{txt}(66,987 missing values generated)

{com}.   gen effect_l_hc=. //low value of 95% confidence interval
{txt}(66,987 missing values generated)

{com}.  gen effect_u_hc=. // high value of 95% confidence interval
{txt}(66,987 missing values generated)

{com}.  
. 
.   
. foreach k of numlist  25 100 {c -(}
{txt}  2{com}.  sum eff_ideol_`k', meanonly
{txt}  3{com}.  replace effect_hc=r(mean) in `k'
{txt}  4{com}.  centile eff_ideol_`k', centile(2.5)
{txt}  5{com}.   replace effect_l_hc=r(c_1) in `k'
{txt}  6{com}.  centile eff_ideol_`k', centile(97.5)
{txt}  7{com}.   replace effect_u_hc=r(c_1) in `k'
{txt}  8{com}.   {c )-}
{txt}(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideol_25 {c |}{col 14}{res}     1,000{col 29}    2.5{col 39} .0047918{col 55} .0043657{col 67} .0051368{txt}
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideol_25 {c |}{col 14}{res}     1,000{col 29}   97.5{col 39} .0154127{col 55} .0150198{col 67} .0158107{txt}
(1 real change made)
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideo~100 {c |}{col 14}{res}     1,000{col 29}    2.5{col 39} .0071526{col 55}  .006866{col 67} .0075222{txt}
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideo~100 {c |}{col 14}{res}     1,000{col 29}   97.5{col 39} .0174867{col 55} .0170044{col 67} .0178144{txt}
(1 real change made)

{com}.   
.   *** The marginal effect of ideological voting when:
.   * low political efficacy, low corruption: 
. list effect_lc effect_l_lc effect_u_lc in 25
{txt}
     {c TLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c TRC}
     {c |} {res}eff~t_lc   eff~l_lc   eff~u_lc {txt}{c |}
     {c LT}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
 25. {c |} {res}.0150983   .0094816   .0212077 {txt}{c |}
     {c BLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c BRC}

{com}. 
.    * low political efficacy, high corruption: 
. list effect_hc effect_l_hc effect_u_hc in 25 
{txt}
     {c TLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c TRC}
     {c |} {res}eff~t_hc   eff~l_hc   eff~u_hc {txt}{c |}
     {c LT}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
 25. {c |} {res}.0100675   .0047918   .0154127 {txt}{c |}
     {c BLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c BRC}

{com}. 
.    * high political efficacy, low corruption: 
. list effect_lc effect_l_lc effect_u_lc in 100
{txt}
     {c TLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c TRC}
     {c |} {res}eff~t_lc   eff~l_lc   eff~u_lc {txt}{c |}
     {c LT}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
100. {c |} {res}.0227053   .0166601   .0292108 {txt}{c |}
     {c BLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c BRC}

{com}.   
.    * high political efficacy, high corruption: 
. list effect_hc effect_l_hc effect_u_hc in 100
{txt}
     {c TLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c TRC}
     {c |} {res}eff~t_hc   eff~l_hc   eff~u_hc {txt}{c |}
     {c LT}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
100. {c |} {res}.0119624   .0071526   .0174867 {txt}{c |}
     {c BLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c BRC}

{com}. 
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\burlacue\Dropbox\Corruption papper\DATAVERSE\marginal_effect_model6.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}19 Oct 2017, 12:41:07
{txt}{.-}
{smcl}
{txt}{sf}{ul off}